package cn.wolfcode.crm.query;

import cn.wolfcode.crm.util.DateUtil;
import com.alibaba.druid.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @program: crm
 * @description:
 * @author: Mr.chen
 * @create: 2018-07-07 23:17
 **/
@Setter
@Getter
public class EmployeeQueryObject extends QueryObject {
    //排序的列
    private String sort;
    //排序的方式
    private String order;

    private String keyword;

    private Long deptId;

    Date date = new Date();
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT-8")
    private Date startDate;

    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT-8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    public Date getEndDate(){
        if (endDate != null){
            return DateUtil.getEndDate(endDate);
        }
        return null;
    }

    public String getKeyword() {

        return StringUtils.isEmpty(keyword) ? null : keyword;
    }

    public String getSort() {
        return StringUtils.isEmpty(sort) ? null : sort;
    }

    public String getOrder() {
        return StringUtils.isEmpty(order) ? "" : order;
    }
}
